package com.hjxr.sysadmin.zsj.service.impl;

import java.util.List;

import com.hjxr.framework.config.ServerConfig;
import com.hjxr.sysadmin.zsj.domain.CheckMessageZ;
import com.hjxr.sysadmin.zsj.mapper.CheckMessageZMapper;
import com.hjxr.sysadmin.zsj.service.ICheckMessageZService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 招商意向需求Service业务层处理
 *
 * @author hjxr
 * @date 2021-03-22
 */
@Service
public class CheckMessageZServiceImpl implements ICheckMessageZService
{
    @Autowired
    private CheckMessageZMapper checkMessageZMapper;
    @Autowired
    private ServerConfig serverConfig;

    /**
     * 查询招商意向需求
     *
     * @param checkCid 招商意向需求ID
     * @return 招商意向需求
     */
    @Override
    public CheckMessageZ selectCheckMessageZById(Long checkCid)
    {
        CheckMessageZ checkMessageZ = checkMessageZMapper.selectCheckMessageZById(checkCid);
        if (checkMessageZ != null && checkMessageZ.getCheckPhotoaddress() != null){
            checkMessageZ.setRealPhotoaddress(serverConfig.getUrl() + checkMessageZ.getCheckPhotoaddress());
        }
        return checkMessageZ;
    }

    /**
     * 查询招商意向需求列表
     *
     * @param checkMessageZ 招商意向需求
     * @return 招商意向需求
     */
    @Override
    public List<CheckMessageZ> selectCheckMessageZList(CheckMessageZ checkMessageZ)
    {
        List<CheckMessageZ> list = checkMessageZMapper.selectCheckMessageZList(checkMessageZ);
        if (list != null && list.size() > 0) {
            for (CheckMessageZ checkMessageZ1 : list) {
                if (checkMessageZ1 != null && checkMessageZ1.getCheckPhotoaddress() != null){
                    checkMessageZ1.setRealPhotoaddress(serverConfig.getUrl() + checkMessageZ1.getCheckPhotoaddress());
                }
            }
        }
        return list;
    }

    /**
     * 新增招商意向需求
     *
     * @param checkMessageZ 招商意向需求
     * @return 结果
     */
    @Override
    public int insertCheckMessageZ(CheckMessageZ checkMessageZ)
    {
        return checkMessageZMapper.insertCheckMessageZ(checkMessageZ);
    }

    /**
     * 修改招商意向需求
     *
     * @param checkMessageZ 招商意向需求
     * @return 结果
     */
    @Override
    public int updateCheckMessageZ(CheckMessageZ checkMessageZ)
    {
        return checkMessageZMapper.updateCheckMessageZ(checkMessageZ);
    }

    /**
     * 批量删除招商意向需求
     *
     * @param checkCids 需要删除的招商意向需求ID
     * @return 结果
     */
    @Override
    public int deleteCheckMessageZByIds(Long[] checkCids)
    {
        return checkMessageZMapper.deleteCheckMessageZByIds(checkCids);
    }

    /**
     * 删除招商意向需求信息
     *
     * @param checkCid 招商意向需求ID
     * @return 结果
     */
    @Override
    public int deleteCheckMessageZById(Long checkCid)
    {
        return checkMessageZMapper.deleteCheckMessageZById(checkCid);
    }

    @Override
    public List<CheckMessageZ> cmlist(String companyName) {
        return checkMessageZMapper.cmlist(companyName);
    }
}
